/*
 * Protocol.h
 *
 *  Created on: 2014-3-11
 *      Author: Mahome
 */

#ifndef PROTOCOL_H_
#define PROTOCOL_H_

typedef	struct
{
	ubyte IPNum;
	ubyte OBDData_Len;
	ubyte OBDData_Res[120];
	ubyte GPS_Len;
	ubyte GPS_Res[31];
	ubyte IMEI_Time_Len;
	ubyte IMEI_Time_Res[30];
	ubyte ADCData_Len;
	ubyte ADCData_Res[20];
	uword CANData_Len;				//要上传的CAN消息长度
	ubyte CANData_Res[800];			//要上传的CAN数据,400个自己不一定全部用到
	ubyte ConStat_Len;
	ubyte ConStat_Res[22];
}ResponseStr;
typedef	struct
{
	ulong ulIdleSpeedTime;//怠速时间，4
	ulong ulUnifSpeedTime;//匀速时间，4
	ulong ulAcceSpeedTime;//加速时间，4
	ulong ulDeceSpeedTime;//减速时间，4
	ulong ulEnerStatistics;//能耗总量/修改成SD卡记录总量，4
	float ulTotalMileage;//返回总里程单位是m，4
	uword CRC;			//前面值的CRC计算，2
	uword uwBat_V;//电池电压，2
	uword uwBat_i;//电池电流，2
	float uwVehicleSpeed_Curr;//当前车速信息，4
	float uwVehicleSpeed_Ahead;//前一时刻车速信息，4
	ubyte ubSpeedMode;//模式标记，1
}StrStatistics;

extern ubyte Message_IMEI15[15];//15位IMEI号
extern uint8_t GPRS_SendBuff[500];//GPRS的发送buff
extern uint16_t GPRS_SendLength;
extern ResponseStr TIU_Res;
extern StrStatistics ConditionStatistics;
extern ubyte NEW_CAN0;
extern ubyte NEW_CAN1;
extern void UpdateTIU_Res_100msTask(void);
extern void FlashLED_100msTask(ubyte lightTimes);
extern void ReflashSampleVlv_100msTask(void);
extern void GetIMEI(ubyte* data,uword Len);
extern void Protocol_CANInitial(void);
extern void Protocol_GetCANMsg1ms(void);
extern void Pack_GPRS(void);
extern void Pack_GPRS4Rec(void);
#endif /* PROTOCOL_H_ */
